package com.example.servlet_Demo;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class WelcomeServlet2 extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doPost-----");

    }

    @Override
    public void init() throws ServletException {
        super.init();
        //获取Servlet的初始化参数
        String value = super.getInitParameter("servletparamname");
        System.out.println("当前Servlet的参数servletparamname的值是：" + value);
        //获取当前web容器的初始化参数
        String globalparam = super.getServletContext().getInitParameter("globalParam");
        System.out.println("当前web容器的参数globalparam的值是;" + globalparam);
    }

    @Override
    public void destroy() {
        super.destroy();

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
